package com.kaifamiao.month04.day08;

public class Person {

    String name;
    int age;
    int ID;
    String gender;

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", ID=" + ID +
                ", gender='" + gender + '\'' +
                '}';
    }


    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if(obj instanceof  Person){
            return  this.name.equals(((Person) obj).name) && this.age == ((Person) obj).age
                    && this.ID == ((Person) obj).ID && this.gender.equals(((Person) obj).gender);
        }
        return false;
    }

    public int hashCode() {
        final int prime = 31;
        int code = 1;
        code = prime * code + ((name == null) ? 0 : name.hashCode());
        code = prime * code + age;
        code = prime * code + ID;
        code = prime * code + ((gender == null) ? 0 : gender.hashCode());
        return code;
    }
}
